const { get_file_list } = require("../utils/file_tool");
const { BaseCommand } = require("./base");

class TsSortCommand extends BaseCommand {
    async execute() {
        const ts_plus = require("typescript-plus");
        const files = get_file_list(this.selfData.src);
        const program = ts_plus.createProgram(files, {
            reorderFiles: true,
        });
        const ret = ts_plus.reorderSourceFiles(program);
        return ret.sortedFileNames;
    }
}

module.exports = {
    TsSortCommand,
};
